package org.cug.config;

import org.cug.interceptors.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;//注入注册器
    //将自定义的拦截器注册到web当中
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**","/coursedesign")  // 明确拦截/user/下的所有路径
                .excludePathPatterns(
                        "/user/login", "/user/register",
                        "/swagger-ui.html", // Swagger UI界面
                        "/v2/api-docs", "/v3/api-docs", // Swagger的API文档路径
                        "/swagger-resources/**", // Swagger的资源路径
                        "/webjars/**", // Swagger的Webjars
                        "/swagger-ui/**", // Swagger UI的新版路径（Swagger 3.x）
                        "/api-docs/**" // API文档的路径
                );
    }
}
